﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
using WPFInterview.InterviewDataSetTableAdapters;

namespace WPFInterview.DB
{
    public class DBTest : IQuestion
    {
        public string TestName
        {
            get { return "Database - Databinding"; }          
        }

        public UserControl getUserControl()
        {
            return new DatabaseQuestion();
        }
    }


    /// <summary>
    /// Interaction logic for DatabaseQuestion.xaml
    /// </summary>
    public partial class DatabaseQuestion : UserControl
    {
        public DatabaseQuestion()
        {
            InitializeComponent();

            InterviewDataSet dbset = new InterviewDataSet();
            QuestionTableAdapter adapter = new QuestionTableAdapter();
            adapter.Fill(dbset.Question);

            // Fill out the list by query the data from the data set.
            _listQuestions.Items.Clear();
            foreach (DataRow row in dbset.Question.Rows)
            {
                string category = (string)row["Category"];
                string content = (string)row["Content"];
                _listQuestions.Items.Add(category);
            }

            this.DataContext = dbset;
            this.Loaded += new RoutedEventHandler(Grid_Loaded);
        }

        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}
